-
Notifications
You must be signed in to change notification settings - Fork 88
feat: unified combiner for multiple signing schemes aggregation #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: unified combiner for multiple signing schemes aggregation #799
Conversation
…igning schemes signature aggregation
…007-js-sdk-add-frost-support-unified-combiner # Conflicts: # local-tests/tests/testUseEoaSessionSigsToPkpSign.ts # packages/constants/src/lib/constants/curves.ts # packages/core/src/lib/lit-core.ts # packages/crypto/src/lib/crypto.ts # packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts # packages/pkp-base/src/lib/pkp-base.ts # packages/types/src/lib/interfaces.ts
…e extra validation leaving it as consumer responsibility
Ansonhkg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we can use zod for all data transformation, but we can have a follow up PR for that later.
| devEnv: TinnyEnvironment | ||
| ) => { | ||
| const alice = await devEnv.createRandomPerson(); | ||
| const signingSchemeConfigs: SigningSchemeConfig[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have this config in constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is just to apply more validations later in this test. Doesn't have much value in real scenarios as we are not doing signature parsing or validation anymore
| throw new Error(`Expected "publicKey" in runWithSessionSigs`); | ||
| } | ||
| // -- Combined signature format assertions | ||
| for (const hexString of [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we use zod schema instead?
| if (!runWithSessionSigs.signature.startsWith('0x')) { | ||
| throw new Error(`Expected "signature" to start with 0x`); | ||
| } | ||
| if (signingSchemeConfig.recoversPublicKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we use zod schema here?
eg.
const validConfig = SigningSchemeConfigSchema.parse(signingSchemeConfig);
const validSignature = PKPSignatureSchema.parse(pkpSignature);
Description
This PR adds multiple signing schemes (Ecdsa and Frost) support sending such scheme to the nodes
Migration guide
SigTypeto define signing schemesLitNodeClientNodeJs::pkpSign,LitNodeClientNodeJs::ExecuteJsResponse,PKPBase (and childs)::runLitAction/runSignall now returnLitNodeSignatures which include0x${string}values instead of generic strings in hex and{ r, s }signatures. all their types have been updatedLitNodeClientNodeJs::pkpSignnow takes the plain message inmessageToSignparam instead of the hashed valuetoSign(unifying frost and ecdsa behaviour, hashing internally when the signing scheme requires it). Also requires the newsigningSchemeparamLitNodeClientNodeJs::executeJsreturns all keys that it signs, not just the first oneLitCore::computeHDPubKeydoesn't accept signing scheme anymore. Will always use ECDSA K256 (where PKPs live). Same for @lit-protocol/cryptocomputeHDPubKeydecryptWithSignatureSharescombineEcdsaSharesreplaced withcombineExecuteJsNodeSharesandcombinePKPSignNodeSharesecdsaCombine,ecdsaVerifyandecdsaCombineAndVerify. All replaced withunifiedCombineAndVerifyDev changes
Most notable change will be in
litNodeClient.pkpSignthat now requires the unhashed message inmessageToSignand a signing scheme,SchnorrK256Sha256will replicate previous networks behaviorWhen using
pkpSign,executeJsfrom LitNodeClient or any PKP*Wallet, now consider that the returned signature will be in0x${string}format and not have anymore components{ r, s }Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
testUseEoaSessionSigsToPkpSignto call pkpSign with all supported signing schemesChecklist: